package com.xiecong.aspect;


import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.core.annotation.Order;

@Slf4j
//@Aspect
//@Component
@Order(1)
public class DemoAspect {
    //切入点方法（公共的切入点表达式）
    @Pointcut("@annotation(com.xiecong.aspect.annotation.LogOperation)")
    public void pt(){}
    //环绕通知
    //@Around("pt()")
    public Object around(ProceedingJoinPoint pjp) throws Throwable {
        log.info("around......");
        Object result = pjp.proceed();
        return result;
    }
    //前置通知（引用切入点）
    @Before("pt()")
    public void before(JoinPoint joinPoint){
        log.info("before......");
    }
    //后置通知
    //@After("pt()")
    public void after(JoinPoint joinPoint){
        log.info("after......");
    }
    //返回后通知（程序在正常执行的情况下，会执行的后置通知）
    //@AfterReturning("pt()")
    public void afterReturning(JoinPoint joinPoint){
        log.info("afterReturning......");
    }
    //异常通知（程序在出现异常的情况下，执行的后置通知）
    //@AfterThrowing("pt()")
    public void afterThrowing(JoinPoint joinPoint){
        log.info("afterThrowing......");
    }
}
